package com.ruoyi.web.controller.dict;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.personnel.vo.HandleDictForTypeVO;
import com.ruoyi.personnel.vo.HandleDictVO;
import com.ruoyi.system.service.ISysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 获取字典数据
 */
@Controller
@RequestMapping("/wx/dict")
public class HandleDictController extends BaseController {

    @Autowired
    private ISysDictDataService dictDataService;

    /**
     * 根据字典类型，获取字典数据
     *
     * @return
     */
    @PostMapping("/list")
    @ResponseBody
    public AjaxResult getType(@Validated @RequestBody HandleDictForTypeVO handleDictForTypeVO) {
        return dictDataService.selectDictDataByType2(handleDictForTypeVO);
    }

    /**
     * 根据字典类型和字典键值查询字典数据信息
     *
     * @return 字典标签
     */
    @PostMapping("/list2")
    @ResponseBody
    public AjaxResult getLabel(@Validated @RequestBody HandleDictVO handleDictVO) {
        return dictDataService.selectDictLabel2(handleDictVO);
    }
}
